module UrlHelper
    def url_saved_by_user(url)
        url_id = get_url_by_website(url)
        UsersUrls.find(:first, :conditions => ["user_id=? and url_id=?", session[:user], url_id])
    end
    
    def create_users_urls_with_link(link, user)
        uu = UsersUrls.new
        uu.url_id = link.id
        uu.user_id = user
        uu.note = link.note
        uu.description = link.description
        uu.collected_at = link.last_collected_at
        uu
    end
    
    def get_url_by_website(url)
        Link.find(:first, :conditions => ["body=?", url])
    end
end
